<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../public/js/vue.js"></script>
</head>
<body>
  <!-- --------------------------------------------- -->
  <!-- View 层 -->
  <div id="app">
    <div>{{"小飘体重：" + count}}</div>
    <button @click="add()">+</button>
    <button @click="sum()">-</button>
  </div>
  <!-- --------------------------------------------- -->
  <script>
    // View 中的数据修改和 Model 之间的通讯 都由 viwemodel层去处理, Vue 实例即为 View Model 
    const app = new Vue({  // ------- View Model -------
      el: "#app",
      // --------------------------------------------
      // Model 层
      data() {
        return {
          count:90
        }
      },
      methods:{
        add() {
          if(this.count >= 95) {
            alert("我家孔小飘是不可能再长胖了！！！")
          }
          this.count++
        },
        sum() {
          if(this.count <= 80) {
            alert("不能再瘦了，要成闪电了！！！")
          }
          this.count--
        }
      }
      // ----------------------------------------------
    })
  </script>
</body>
</html>